<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        li {
            list-style: none;
        }

        .banner {
            width: 400px;
            height: 300px;
            margin: auto;
            position: relative;
        }

        .banner ul li {
            width: 400px;
            height: 300px;
            text-align: center;
            line-height: 300px;
            font-size: 50px;
            position: absolute;
            top: 0;
            background-color: #f00;

            opacity: 0;
            transition: .5s;
        }

        span {
            width: 30px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            background-color: #000;
            color: #fff;
            position: absolute;
            top: 0;
            bottom: 0;
            margin: auto;
        }

        .next {
            right: 0;
        }

        ol {
            position: absolute;
            width: 100%;
            bottom: 10px;
            display: flex;
            justify-content: center;
        }

        ol li {
            width: 20px;
            height: 20px;
            background-color: #ff0;
            margin: 10px;
        }
    </style>
</head>

<body>

    <div class="banner">
        <ul>
            <!-- <li style="opacity: 1;">
                <img src="" alt="">
            </li> -->
        </ul>
        <span class="prev">&lt;</span>
        <span class="next">&gt;</span>
        <ol>
            <!-- <li style="background-color: #0f0;"></li> -->
        </ol>
    </div>

    <script>

        var imgArr = [
            '1.jpg',
            '2.jpg',
            '3.jpg',
            '4.jpg',
        ]

        var imgs = '';
        imgArr.forEach(function (v) {
            imgs += `
                <li>
                    <img src="" alt="">
                </li>
            `
        })

        var oUl = document.querySelector('ul');
        oUl.innerHTML = imgs;



        // 小点
        var dots = '';
        imgArr.forEach(function (v) {
            dots += `<li></li>`
        })

        var oOl = document.querySelector('ol');
        oOl.innerHTML = dots;


        var oLis = document.querySelectorAll('ul li');

        // 给第一张图显示一下
        oLis[0].style.opacity = '1';
        

    </script>

</body>

</html>